package com.dankegongyu.lib.share.bean;

import android.app.Activity;
import android.graphics.Bitmap;

import com.dankegongyu.lib.share.DKShareCallback;
import com.dankegongyu.lib.share.DKShareUtil;
import com.dankegongyu.lib.share.DK_SHARE_MEDIA;

import java.io.File;

/**
 * 分享图片
 *
 * @author wupuquan
 * @version 1.0
 * @since 2018/3/12 17:58
 */
public class DKShareImage extends DKShareObject<DKShareImage> {

    private String imageUrl; //网络图片
    private int imageRes; //资源文件
    private Bitmap bitmap; //bitmap文件
    private File file; //本地文件
    private byte[] bytes; //字节流

    private DKShareImage(Activity activity) {
        super(activity);
    }

    public static DKShareImage with(Activity activity) {
        return new DKShareImage(activity);
    }

    /**
     * 网络图片
     *
     * @param imageUrl 图片地址
     */
    public DKShareImage setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
        return this;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    /**
     * 资源文件
     *
     * @param imageRes 本地drawable文件
     */
    public DKShareImage setImageRes(int imageRes) {
        this.imageRes = imageRes;
        return this;
    }

    public int getImageRes() {
        return imageRes;
    }

    /**
     * bitmap文件
     *
     * @param bitmap bitmap图片
     */
    public DKShareImage setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
        return this;
    }

    public Bitmap getBitmap() {
        return bitmap;
    }

    /**
     * 本地文件
     *
     * @param file 本地图片文件
     */
    public DKShareImage setFile(File file) {
        this.file = file;
        return this;
    }

    public File getFile() {
        return file;
    }

    /**
     * 字节流
     *
     * @param bytes 字节流
     */
    public DKShareImage setBytes(byte[] bytes) {
        this.bytes = bytes;
        return this;
    }

    public byte[] getBytes() {
        return bytes;
    }

    @Override
    public void show() {
        DKShareUtil.shareDefault(this, null);
    }

    @Override
    public void show(DKShareCallback shareCallback) {
        DKShareUtil.shareDefault(this, shareCallback);
    }

    @Override
    public void shareDirect(DK_SHARE_MEDIA dk_share_media) {
        shareDirect(dk_share_media, null);
    }

    @Override
    public void shareDirect(DK_SHARE_MEDIA dk_share_media, DKShareCallback shareCallback) {
        DKShareUtil.share(dk_share_media.getName(), this, shareCallback);
    }

    @Override
    public DKMediaType getShareMedia() {
        return DKMediaType.IMAGE;
    }

}
